import { request } from "./request.js"

//获取角色列表
export function getroles() {
    return request({
        url: "/roles",
        method: "get"
    })
}

//添加角色 
export function addroles(roleform) {
    return request({
        url: "/roles",
        method: "post",
        data: {
            roleName: roleform.roleName,
            roleDesc: roleform.roleDesc
        }
    })
}

//删除角色数据
export function deleteroles(id) {
    return request({
        url: `/roles/${id}`,
        method: "delete"
    })
}

//获取全部角色权限
export function getroleall() {
    return request({
        url: "rights/tree",
        method: "get"
    })
}




//编辑角色数据
export function editroles(id, editform) {
    return request({
        url: `/roles/${id}`,
        method: "put",
        data: {
            roleName: editform.roleName,
            roleDesc: editform.roleDesc
        }
    })
}

//删除角色指定权限
export function deleterightid(rightId, roleId) {
    return request({
        url: `roles/${roleId}/rights/${rightId}`,
        method: "delete"
    })
}


//添加角色权限
export function addrole(roleId, rids) {
    return request({
        url: `roles/${roleId}/rights`,
        method: "post",
        data: {
            rids
        }

    })
}